import time

from fastapi import APIRouter,Depends
import datetime

from backend.app.app.crud_pro.tb_userpro_base import save_project_db
# from backend.app.app.crud_pro.tb_userpro_base import get_all_project
from backend.app.app.models.project import save_project
from backend.app.app.api.api_v1.user import verify_token_user

router_new_project = APIRouter(prefix="/new_project", tags=["新建工程"])

@router_new_project.post("/save",name="存储工程")
async def save_project(project_inf:save_project,ver = Depends(verify_token_user)):
    now = datetime.datetime.now().strftime("%Y-%m-%d")
    proj_id = str(round(time.time()*1e3))
    a = save_project_db(project_inf.user_ID,proj_id,
                    project_inf.proj_Name,now,now,project_inf.remark)
    return {"save":a,"ver_token":ver}


# @router_new_project.post("/get_all_pro",name="获取所有工程")
# async def get_all_pro(ver = Depends(verify_token_user)):
#     all_project  = get_all_project()
#     return {"all_project":all_project,"ver_token":ver}
